<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
        }
        .tab-container {
            display: flex;
            border-bottom: 1px solid #ccc;
        }
        .tab-button {
            background-color: inherit;
            border: none;
            outline: none;
            cursor: pointer;
            padding: 14px 16px;
            transition: 0.3s;
        }
        .tab-button:hover {
            background-color: #ddd;
        }
        .tab-content {
            display: none;
            padding: 6px 12px;
            border: 1px solid #ccc;
            border-top: none;
        }
        .active-tab {
            background-color: #ccc;
        }
        .active-content {
            display: block;
        }
    </style>
</head>
<body>

<div class="tab-container">
    <button class="tab-button active-tab" onclick="openTab(event, 'css')">CSS 属性</button>
    <button class="tab-button" onclick="openTab(event, 'component')">组件属性</button>
</div>

<div id="css" class="tab-content active-content">
    <h2>CSS 属性</h2>
    <p>这里是一些常见的 CSS 属性：</p>
    <ul>
        <li><code>color</code>: 设置文本颜色。</li>
        <li><code>background-color</code>: 设置背景颜色。</li>
        <li><code>font-size</code>: 设置字体大小。</li>
        <li><code>margin</code>: 设置外边距。</li>
        <li><code>padding</code>: 设置内边距。</li>
    </ul>
</div>

<div id="component" class="tab-content">
    <h2>组件属性</h2>
    <p>这里是一些常见的组件属性：</p>
    <ul>
        <li><code>id</code>: 唯一标识元素的 ID。</li>
        <li><code>class</code>: 为元素指定一个或多个类名。</li>
        <li><code>src</code>: 指定媒体文件的 URL。</li>
        <li><code>href</code>: 指定链接的目标 URL。</li>
        <li><code>alt</code>: 提供图像的替代文本。</li>
    </ul>
</div>

<script>
    function openTab(evt, tabName) {
        var i, tabcontent, tablinks;
        tabcontent = document.getElementsByClassName("tab-content");
        for (i = 0; i < tabcontent.length; i++) {
            tabcontent[i].classList.remove("active-content");
        }
        tablinks = document.getElementsByClassName("tab-button");
        for (i = 0; i < tablinks.length; i++) {
            tablinks[i].classList.remove("active-tab");
        }
        document.getElementById(tabName).classList.add("active-content");
        evt.currentTarget.classList.add("active-tab");
    }
</script>

</body>
</html>


